package com.niuwa.p2p.action.customerservice;

import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.niuwa.p2p.action.JsonAction;
import com.niuwa.p2p.core.mvc.entity.PageBean;
import com.niuwa.p2p.entity.PageQuery;
import com.niuwa.p2p.entity.custservice.CustServiceTraceLog;
import com.niuwa.p2p.entity.custservice.CustServiceUser;
import com.niuwa.p2p.service.custService.ICustServiceService;
import com.opensymphony.xwork2.ActionContext;

/**
 * @author futianliang
 * @date 2015年4月28日
 */
public class CustomerServiceDetailAction extends JsonAction {
	private static final long serialVersionUID = -8900124777631535966L;
	/** 日志 */
	private static Logger logger = Logger.getLogger(CustomerServiceDetailAction.class);
	@Autowired
	private ICustServiceService custService;
	private Long id;
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Action(value ="gotoCustomerServiceDetailInfo")
	public String gotoCustomerServiceDetailInfo() {
		CustServiceUser custUser = custService.selectByPrimaryKey(id);
		ActionContext context = ActionContext.getContext();
		context.put("custUser", custUser);
		return "customerServiceDetail";
	}

	// 跟进记录
	@Action("getCustServiceTraceLogList")
	public String getCustServiceTraceLogList() throws Exception {
		setObjectReSult(queryPage());
		logger.info("CustServiceTraceLog action execute success");
		return NONE;
	}
	@Action(value ="gotoList")
	public String goToList(){
		return "listTest";
	}
	private PageBean<CustServiceTraceLog> queryPage() {

		// 获取查询参数
		Map<String, Object> paramMap = getParamMap();
		int totalCount = custService.getCustServiceTraceLogListCount(paramMap);
		PageBean<CustServiceTraceLog> page = new PageBean<CustServiceTraceLog>(totalCount);
		// 当前页
		page.setPage(((PageQuery) paramMap.get(PageQuery.PAGEQUERY)).getPage());
		page.setRows(custService.getCustServiceTraceLogList(paramMap));
		return page;
	}

	
}
